package com.myproject.mall.seller.controller;

import com.myproject.mall.common.result.HttpResult;
import com.myproject.mall.domain.entity.Brand;
import com.myproject.mall.seller.service.IBrandService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "品牌接口")
@RestController
@RequestMapping("/api/brand")
@RequiredArgsConstructor
public class BrandController {
    private final IBrandService brandService;

    @Operation(summary = "注册品牌")
    @PostMapping("/add")
    public HttpResult<Void> addBrand(@RequestBody Brand  brand) {
        brandService.addBrand(brand);
        return HttpResult.success();
    }

    @Operation(summary = "获取品牌")
    @GetMapping("/get")
    public HttpResult<Brand> getBrand(@RequestParam Long id) {
        return HttpResult.success(brandService.getBrand(id));
    }

    @Operation(summary = "获取所有品牌")
    @GetMapping("/getAll")
    public HttpResult<List<Brand>> getAllBrand() {
        return HttpResult.success(brandService.getAllBrand());
    }

    @Operation(summary = "更新品牌")
    @PostMapping("/update")
    public HttpResult<Void> updateBrand(@RequestBody Brand brand) {
        brandService.updateBrand(brand);
        return HttpResult.success();
    }

    @Operation(summary = "删除品牌")
    @GetMapping("/delete")
    public HttpResult<Void> deleteBrand(@RequestParam Long id) {
        brandService.deleteBrand(id);
        return HttpResult.success();
    }
}
